﻿using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Inscriptionem.Extensions
{
    public static class StringExtensions
    {
        public static bool IsNumeric(this string value)
        {
            decimal number = decimal.Zero;
            if (decimal.TryParse(value, System.Globalization.NumberStyles.Any, null, out number))
            {
                return true;
            }

            return false;
        }

        public static bool EndsWithAny(this string Value, IEnumerable<string> Items)
        {
            foreach (string item in Items)
            {
                if (Value.EndsWith(item))
                {
                    return true;
                }
            }
            return false;
        }

        public static bool ContainsAny(this string Value, IEnumerable<string> Items)
        {
            foreach (string item in Items)
            {
                if (Value.Contains(item))
                {
                    return true;
                }
            }
            return false;
        }

        public static string StripHTML(this string Value)
        {
            return Regex.Replace(Value, @"<[^>]*>", string.Empty, RegexOptions.Compiled | RegexOptions.Singleline);
        }
    }
}